package br.ufrj.ppgi.infovis.util;

import java.util.HashMap;
import java.util.Map;

import org.mt4j.MTApplication;

import processing.core.PImage;

public class TextureCache {
	private static Map<String,PImage> imgCache;
	
	private static boolean initialized = false;
	
	
    /* *** Button constants *** */
    public static final String    DATA_FOLDER                        = "br" + MTApplication.separator + 
    																   "ufrj" + MTApplication.separator + 
    																   "ppgi" + MTApplication.separator + 
    																   "infovis" + MTApplication.separator + 
    																   "data" + MTApplication.separator;
    public static final String    BTN_ADD         = DATA_FOLDER + "bt_mais.png";
    public static final String    TXT_ADD         = DATA_FOLDER + "bt-add2.png";
    public static final String    BTN_DELETE      = DATA_FOLDER + "TrashIconEmpty.png";    
    public static final String    BTN_LINK        = DATA_FOLDER + "bt_link.png";
    public static final String    BTN_UNLINK      = DATA_FOLDER + "bt_unlink.png";
    public static final String    BTN_ORGANIZE    = DATA_FOLDER + "bt_organize.png";
    public static final String    BTN_IMPORT      = DATA_FOLDER + "bt_import.png";
    public static final String    BTN_EXPORT      = DATA_FOLDER + "bt_export.png";
    public static final String    BG_WOOD      	  = DATA_FOLDER + "bg-texture.jpg";
   // public static final String    BG_GRANITE	  = DATA_FOLDER + "txtgranito.jpg";
	
	public static void initTextureCache(MTApplication mta) {
		if (initialized) return;
		imgCache = new HashMap<String, PImage>();
		
		imgCache.put(BTN_ADD,mta.loadImage(BTN_ADD));
		imgCache.put(BTN_DELETE,mta.loadImage(BTN_DELETE));
		imgCache.put(BTN_LINK,mta.loadImage(BTN_LINK));
		imgCache.put(BTN_UNLINK,mta.loadImage(BTN_UNLINK));
		imgCache.put(BTN_ORGANIZE,mta.loadImage(BTN_ORGANIZE));
		imgCache.put(BTN_IMPORT,mta.loadImage(BTN_IMPORT));
		imgCache.put(BTN_EXPORT,mta.loadImage(BTN_EXPORT));
		imgCache.put(BG_WOOD,mta.loadImage(BG_WOOD));
		imgCache.put(TXT_ADD,mta.loadImage(TXT_ADD));
//		imgCache.put(BG_GRANITE,mta.loadImage(BG_GRANITE));
		
		initialized = true;
	}
	
	public static PImage getTexture(String key) {
		return imgCache.get(key);
	}
	
	
}
